/*
 * @Descripttion: 
 * @version: 
 * @Author: yuanliutech
 * @Date: 2022-09-22 11:55:27
 * @LastEditors: yuanliutech@lwj
 * @LastEditTime: 2022-09-22 13:43:26
 */
// pages/mine/cropper/cropper.js
const app = getApp()
var cropper
Page({
  onLoad: function (options) {
    // 根据标签id，获取到image-cropper对象，存储在全局变量cropper中
    cropper = this.selectComponent("#my-cropper");
    let tempFilePaths = options.tempFilePaths
    // 设置标签属性
    this.setData({
      // 从图片选择界面传原图临时文件地址给src
      src: tempFilePaths,
      // 设置裁剪框宽高比值为 1（宽:高=1:1=1）
      aspectRatio: 1,
      // 设置是否等比缩放
      isProportion: true,
      // 设置裁剪后的图片质量
      quality: 1,
    })
  },
  //裁剪返回按钮
  back_add() {
    wx.navigateBack()
  },
  //裁剪确定按钮
  confirm() {
    var pages = getCurrentPages(); //获取加载的页面
    var currentPage = pages[pages.length - 2]; //获取当前页面的对象
    // console.log(currentPage,"currentPage");
    var url = currentPage.route; //当前页面url
    cropper.getImagePath(res => {
      wx.redirectTo({
        url: '/pages/personal-inside-page/user-info/user-info?path=' + res.path + '&btn=' + false,
      })
    })
  },
})